<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of RepFacturaDetallada
 *
 * @author Bryan Cruz
 */
class RepStudCatedratico extends ReportBase {

    public $where = NULL;
    public $stud = "";

    function __construct() {
        $this->callbackSql = "cbSqlGenerador"; //funcion que genera sql
        $this->callbackRow = "funcRows"; //funcion para cada fila generada
        $this->paramPage = "rpt_studCatedratico_param.php";
        $this->resultPage = "rpt_studCatedratico_resultado.php";
        $this->rootPath = RPT_PATH + "include";
        $this->label = "Consulta de alumnos por catedrático";
        $this->subtitle = $this->label;
    }

    public function cbSqlGenerador() {
        $sql = "SELECT * FROM cllg_teacher_assign ";
        $w = "";

        if (isEmpty(getParam("ID")) || isEmpty(getParam("CYCLE")) || isEmpty(getParam("ASSIGN"))) {
            throw new Exception("<h5 style='color:blue;'>Debe seleccionar todos los parámetros de búsqueda!<h5>");
        } else {
            $w = sprintf("ID=%s", getParam("ASSIGN"));
        }

        $this->lastQuery = isEmpty($w) ? $sql : ("$sql WHERE $w");
    }

    public function generateSQL() {

        $this->cbSqlGenerador();
        #echo $this->lastQuery;
        $sqlRs = $this->db->queryToArray($this->lastQuery);
        $this->lastResult = $sqlRs;
    }

    public function getTypeaheadData($select, $table) {
        $as = "DATA";
        $sqlData = sprintf("SELECT %s AS %s FROM %s", $select, $as, $table);
        $data = $this->db->queryToArray($sqlData);
        $string = "";

        foreach ($data as $d) {
            $string = isEmpty($string) ? $string : "$string,";
            $string.= '"' . $d[$as] . '"';
        }
        $typeahead = "[" . $string . "]";
        return $typeahead;
    }

}

?>
